package com.glsc.ngateway.platform.service.it;

import cn.hutool.core.util.StrUtil;
import com.glsc.ngateway.common.api.common.enums.PlatformConstant;
import com.glsc.ngateway.common.api.platform.dto.it.ParamSearchVirtualDto;
import com.glsc.ngateway.common.api.platform.dto.it.VirtualManageExport;
import com.glsc.ngateway.common.api.platform.dto.it.VirtualManageExportFull;
import com.glsc.ngateway.common.api.platform.dto.user.PlatformUserDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.User;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItApplicationDetail;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItOperation;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItServerDevice;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.it.ItVirtualDevice;
import com.glsc.ngateway.common.base.domain.mysql.gateway.system.SystemMain;
import com.glsc.ngateway.common.base.domainmapper.VirtualRowMapper;
import com.glsc.ngateway.common.base.domainmapper.VirtualRowMapperFull;
import com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it.ItApplicationDetailRepo;
import com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it.ItOperationRepo;
import com.glsc.ngateway.common.base.repo.mysql.gateway.platform.it.ItVirtualDeviceRepo;
import com.glsc.ngateway.common.base.repo.mysql.gateway.platform.system.SystemMainRepository;
import com.glsc.ngateway.platform.service.MailService;
import com.glsc.ngateway.platform.service.UserService;
import com.glsc.ngateway.platform.service.costallocation.BusiSystemInfoService;
import com.glsc.ngateway.platform.service.costallocation.IpInfoService;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;

@Service
public class VirtualService {

    Logger logger = LoggerFactory.getLogger(VirtualService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SequenceService sequenceService;
    @Autowired
    private UserService userService;
    @Autowired
    private ItVirtualDeviceRepo itVirtualDeviceRepo;
    @Resource
    private IpInfoService ipInfoService;
    @Autowired
    private ItOperationRepo itOperationRepo;
    @Autowired
    private ItApplicationDetailRepo itApplicationDetailRepo;
    @Autowired
    private SystemMainRepository systemMainRepository;

    @Autowired
    private ServerService serverService;

    @Autowired
    private MailService mailService;
    @Autowired
    private BusiSystemInfoService busiSystemInfoService;


    public ItVirtualDevice findByDevId(String devId) {
        return itVirtualDeviceRepo.findByDevId(devId);
    }


    public Page<ItVirtualDevice> queryVirtualDevice(Integer page, Integer size, String userId) {

        Pageable pageable = PageRequest.of(page - 1, size);
        Page<ItVirtualDevice> list = itVirtualDeviceRepo.getVirtualDeviceByUser(pageable, userId);
        List<ItVirtualDevice> flist = list.getContent();
        try {
            List<ItOperation> opList = itOperationRepo.findAll();
            List<ItApplicationDetail> mxList = itApplicationDetailRepo.findAll();
            for (ItVirtualDevice s : flist) {
                User user = userService.findByUserId(s.getUserId());
                if (user != null) {
                    s.setDepartment(user.getUserDepartment());
                    s.setUserName(user.getName());
                }
                for (ItOperation op : opList) {
                    if (op.getOpId().equals(s.getBusinessName())) {
                        s.setOpStyle(op.getOpStyle());
                        s.setOpStyleName(PlatformConstant.itSystemType.get(op.getOpStyle()));
                        s.setOpName(op.getOpName());
                        break;
                    }
                }
                for (ItApplicationDetail mx : mxList) {
                    if (mx.getMxId().equals(s.getApplicationDetail())) {
                        s.setMxName(mx.getMxName());
                        break;
                    }
                }
                s.setMachineAreaName(PlatformConstant.itRunEnviron.get(s.getMachineArea()));
            }
        } catch (Exception e) {
            logger.error("queryVirtualDevice异常", e);
        }
        return list;
    }

    //    public String addVirtualDevice(Map<String, Object> virtualDeviceInfo) {
//        String devId = "VD-" + sequenceService.getNextValue("virtual_dev");
//        virtualDeviceInfo.put("devId", devId);
//        virtualDeviceInfo.put("mark", "1");
//        Date currentTime = new Date();
//        virtualDeviceInfo.put("insertTime", currentTime);
////		virtualDeviceInfo.put("updateTime", currentTime);
//        // change the camel-naming to underline-naming
//        virtualDeviceInfo = BeanUtil.camel2Underline(virtualDeviceInfo);
//        generalDataManager.insert("t_virtual_device", virtualDeviceInfo);
//        return devId;
//    }
//
//    public void updateVirtualDevice(Map<String, Object> virtualDeviceInfo) {
//        Date currentTime = new Date();
//        virtualDeviceInfo.put("insertTime", currentTime);
////		virtualDeviceInfo.put("updateTime", currentTime);
//        // change the camel-naming to underline-naming
//        virtualDeviceInfo = BeanUtil.camel2Underline(virtualDeviceInfo);
//        generalDataManager.update("t_virtual_device", virtualDeviceInfo, "dev_id");
//    }

    @Transactional
    public void addOrUpdateVirtual(ItVirtualDevice itVirtualDevice) {
        boolean isAdd = false;
        if (StringUtils.isEmpty(itVirtualDevice.getDevId())) {
            isAdd = true;
            boolean con = true;
            String id = null;
            while (con) {
                String tmpid = "VD-" + sequenceService.getNextValue("virtual_dev");
                logger.info("新增虚拟机，生成唯一标识，临时" + tmpid);
                ItVirtualDevice i = itVirtualDeviceRepo.findByDevId(tmpid);
                if (i == null) {
                    logger.info("新增虚拟机，生成唯一标识，选中" + tmpid);
                    id = tmpid;
                    con = false;
                }
            }
            itVirtualDevice.setDevId(id);
            itVirtualDevice.setMark("1");
        }
        if (StringUtils.isNotEmpty(itVirtualDevice.getUserAccount())) {
            PlatformUserDto u = userService.findByUsername(itVirtualDevice.getUserAccount());
            if (u != null) {
                itVirtualDevice.setUserId(u.getUserid());
            } else {
                logger.info("未找到虚拟机责任人");
//                itVirtualDevice.setUserId(null);
            }
        } else {
            User u = userService.findByUserId(itVirtualDevice.getUserId());
            if (u == null){
                //增加新用户
                try{
                    userService.addUser(itVirtualDevice.getUserId());
                }catch (Exception e){
                    e.printStackTrace();
                    mailService.sendMailToAdmin("IT资产OA回调新增用户失败"+itVirtualDevice.getUserId(),e.getMessage());
                }
            }
//            itVirtualDevice.setUserId(null);//不设置null，一样保存
        }

        try{
            busiSystemInfoService.synchronizeBusiInfoAddOrUpdate(itVirtualDevice,isAdd);
        }catch(Exception e){
            logger.info("虚拟机同步异常-新增或编辑", e);
            String message = e.getMessage();
            if(StringUtils.isBlank(message)){
                message =  Arrays.toString(e.getStackTrace());
            }
            mailService.sendMailToAdmin("虚拟机同步异常-新增或编辑", message);
        }



        String addORupdate = "add";
        ItVirtualDevice oldITserver = new ItVirtualDevice();
        if(!isAdd){
            String devId = itVirtualDevice.getDevId();
            addORupdate = "update";
            ItVirtualDevice temp =findByDevId(devId);
            BeanUtils.copyProperties(temp,oldITserver);
        }
        ItVirtualDevice saved = itVirtualDeviceRepo.save(itVirtualDevice);
        try{
            ipInfoService.synchronizeBaseIpInfoAddOrUpdate(saved,oldITserver,addORupdate);
        }catch(Exception e){
            logger.info("服务器资产同步异常-新增或编辑", e);
            String message = e.getMessage();
            if(StringUtils.isBlank(message)){
                message =  Arrays.toString(e.getStackTrace());
            }
            mailService.sendMailToAdmin("服务器资产同步IP异常-新增或编辑", message);
        }
    }

    public void deleteVirtual(String devId) {
        Optional<ItVirtualDevice> dev = itVirtualDeviceRepo.findById(devId);
        if (dev.isPresent()) {
            try {
                busiSystemInfoService.syncItServerDeviceDelete(devId);
            } catch (Exception e) {
                logger.info("虚拟机同步异常-删除", e);
                String message = e.getMessage();
                if(StringUtils.isBlank(message)){
                    message =  Arrays.toString(e.getStackTrace());
                }
                mailService.sendMailToAdmin("虚拟机同步异常-删除", message);
            }
            try {
                ipInfoService.doOfflineIP(devId);
            } catch (Exception e) {
                logger.info("虚拟机同步删除异常-删除", e);
                String message = e.getMessage();
                if(StringUtils.isBlank(message)){
                    message =  Arrays.toString(e.getStackTrace());
                }
                mailService.sendMailToAdmin("虚拟机同步删除异常-删除", message);
            }

            dev.get().setMark("2");
            itVirtualDeviceRepo.save(dev.get());
        }
    }


//    //搜索虚拟机
//    public List<Map<String, Object>> searchVirtualDevice(String svd, String user_id) {
//        //验证user_id的权限是否为admin
//        List<String> userRoles = userService.getUserAllRolesById(user_id);
//        boolean isAuth = false; //是否有权限新增
//        for (String role : userRoles) {
//            if ("admin".equals(role)) {
//                isAuth = true;
//                break;
//            }
//        }
//        String condition = "";
//        String sql = "";
//        if (isAuth) {
//            sql = "select a.*,b.department from t_virtual_device a left join t_admin_user b on a.user_id = b.user_id  where mark = '1' "
//                    + "and (ip1 like '%" + svd + "%' or ip2 like '%" + svd + "%' or mac1 like '%" + svd + "%' or mac2 like '%" + svd + "%') ";
//        } else {
//            condition += " and user_id = '" + user_id + "'";
//            condition += " order by insert_time desc ";
//            sql = "select a.*,b.department from t_virtual_device a left join t_admin_user b on a.user_id = b.user_id where mark = '1' "
//                    + "and (ip1 like '%" + svd + "%' or ip2 like '%" + svd + "%' or mac1 like '%" + svd + "%' or mac2 like '%" + svd + "%') " + condition;
//        }
//        return BeanUtil.underline2Camel(jdbcTemplate.queryForList(sql));
//    }
//
//
//    //搜索虚拟机名称
//    public List multiSearch(Map<String, Object> virtualDeviceInfo) {
//        String condition = " where a.mark='1' ";
//        String businessName = (String) virtualDeviceInfo.get("businessName");
//        if (!"".equals(businessName) && businessName != null) {
//            condition += " and business_name = '" + businessName + "'";
//        }
//        Integer machineArea = (Integer) virtualDeviceInfo.get("machineArea");
//        if (machineArea != null) {
//            condition += " and machine_area = " + machineArea.intValue();
//        }
//        String applicationDetail = (String) virtualDeviceInfo.get("applicationDetail");
//        if (!"".equals(applicationDetail) && applicationDetail != null) {
//            condition += " and application_detail = '" + applicationDetail + "'";
//        }
//        String userId = (String) virtualDeviceInfo.get("userId");
//        if (!"".equals(userId) && userId != null) {
//            condition += " and a.user_id = '" + userId + "'";
//        }
//        Integer networkSegment = (Integer) virtualDeviceInfo.get("networkSegment");
//        if (networkSegment != null) {
//            condition += " and network_segment = " + networkSegment.intValue();
//        }
//        String virtualName = (String) virtualDeviceInfo.get("virtualName");
//        if (!"".equals(virtualName) && virtualName != null) {
//            condition += " and virtual_name like '%" + virtualName + "%'";
//        }
//        String ip1 = (String) virtualDeviceInfo.get("ip1");
//        if (!"".equals(ip1) && ip1 != null) {
//            condition += " and ip1 = '" + ip1 + "'";
//        }
//        String ip2 = (String) virtualDeviceInfo.get("ip2");
//        if (!"".equals(ip2) && ip2 != null) {
//            condition += " and ip2 = '" + ip2 + "'";
//        }
//        String vcentIp = (String) virtualDeviceInfo.get("vcentIp");
//        if (!"".equals(vcentIp) && vcentIp != null) {
//            condition += " and vcent_ip = '" + vcentIp + "'";
//        }
//        String virtualIp = (String) virtualDeviceInfo.get("virtualIp");
//        if (!"".equals(virtualIp) && virtualIp != null) {
//            condition += " and virtual_ip = '" + virtualIp + "'";
//        }
//        Integer operationSys = (Integer) virtualDeviceInfo.get("operationSys");
//        if (operationSys != null) {
//            condition += " and operation_sys = " + operationSys.intValue();
//        }
//        Integer qj = (Integer) virtualDeviceInfo.get("qj");
//        if (qj != null) {
//            condition += " and qj = " + qj.intValue();
//        }
//        Integer opStyle = (Integer) virtualDeviceInfo.get("opStyle");
//        if (opStyle != null) {
//            condition += " and op_style = " + opStyle.intValue();
//        }
////		String sql = "select * from t_virtual_device"+condition;
//        String sql = "select a.*,b.op_style,c.department from t_virtual_device a left join t_operation b on a.business_name = b.op_id left join t_admin_user c on a.user_id = c.user_id " + condition;
//        return BeanUtil.underline2Camel(jdbcTemplate.queryForList(sql));
//    }


    //搜索虚拟机
    public Page<ItVirtualDevice> searchVirtual(Integer page, Integer size,
                                               String businessName, String applicationDetail, String opStyle,
                                               String machineArea, String virtualName, String ip1, String ip2, String vcentIp,
                                               Integer virtualIp, String operationSys, String qj, String userId, String machineRoom, ParamSearchVirtualDto params) {
        Pageable pageable = PageRequest.of(page - 1, size);

        if (StringUtils.isEmpty(params.getSearchMacParam())){
            params.setSearchMacParam(null);
        }
        if (StringUtils.isEmpty(params.getDevId())){
            params.setDevId(null);
        }

        Page<ItVirtualDevice> list = itVirtualDeviceRepo.searchVirtualDevice(pageable, businessName, applicationDetail, opStyle,
                machineArea, virtualName, ip1, ip2, vcentIp, virtualIp, operationSys, qj, userId,params.getSearchMacParam(),params.getDevId());
        List<ItVirtualDevice> flist = list.getContent();
        try {
            List<SystemMain> opList = systemMainRepository.findAll();
            List<ItApplicationDetail> mxList = itApplicationDetailRepo.findAll();

            List<ItServerDevice> serverlist = serverService.queryAllServer();
            for (ItVirtualDevice s : flist) {
                if (StringUtils.isNotEmpty(s.getUserId())) {
                    User user = userService.findByUserId(s.getUserId());
                    if (user != null) {
                        s.setDepartment(user.getUserDepartment());
                        s.setUserName(user.getName());
                        s.setUserAccount(user.getUsername());
                    }
                }
                //将ip封道list中
                List<String> ipList = new ArrayList<>();
                if(StringUtils.isNotBlank(s.getIp1())){
                    ipList.add(s.getIp1());
                }
                if(StringUtils.isNotBlank(s.getIp2())){
                    ipList.add(s.getIp2());
                }
                if(StringUtils.isNotBlank(s.getIp3())){
                    ipList.add(s.getIp3());
                }
                if(StringUtils.isNotBlank(s.getIp4())){
                    ipList.add(s.getIp4());
                }
                s.setIpList(ipList);
                for (SystemMain op : opList) {
                    if (op.getSystemClassNo().equals(s.getBusinessName())) {
                        s.setOpStyle(op.getMainClass());
//                        s.setOpStyleName(PlatformConstant.itSystemType.get(op.getOpStyle()));
                        s.setOpName(op.getOpName());
                        break;
                    }
                }
                for (ItApplicationDetail mx : mxList) {
                    if (mx.getMxId().equals(s.getApplicationDetail())) {
                        s.setMxName(mx.getMxName());
                        break;
                    }
                }
                for (ItServerDevice sd : serverlist) {
                    if (sd.getDevId().equals(s.getVirtualIp())){
                        s.setMachineRoom(sd.getMachineRoom());
                        break;
                    }
                }

                s.setMachineAreaName(PlatformConstant.itRunEnviron.get(s.getMachineArea()));
            }
        } catch (Exception e) {
            logger.error("searchVirtual搜索异常", e);
        }
        return list;
    }

    //虚拟机数据导出
    public List<VirtualManageExport> exportVirtualOutPut() {
        String sql = "select b.op_name business_name, " +
                "(select dict_value from t_it_dict c where c.zd_id = a.network_segment) network_segment, " +
                "mx_name application_detail, " +
                "case when a.machine_area=0 then '生产网' when a.machine_area=1 then '办公网' " +
                "when a.machine_area=2 then '测试网' end machine_area, " +
                "virtual_name, " +
                "(select dict_value from t_it_dict f where f.zd_id = a.operation_sys) operation_sys, " +
                "ip1,ip2,vcent_ip, " +
                "(select dict_value from t_it_dict g where g.zd_id = a.cpu) cpu, " +
                "(select dict_value from t_it_dict h where h.zd_id = a.memory) memory, " +
                "(select ip1 from t_it_server_device j where j.dev_id = a.virtual_ip) virtual_ip, " +
                "name ,department, " +
                "case when a.qj=1 then 'Nutanix_Cluster' when a.qj=2 then 'MainCluster' " +
                "when a.qj=3 then 'VMware_Cluster' when a.qj=4 then 'zbCluster' end qj, " +
//				     "(select dict_value from t_dict i where i.zd_id = a.qj) qj, " +               //20201207修复群集翻译问题
                "case when mark=1 then '正常' when mark=2 then '已删除' end mark " +
                "from t_it_virtual_device a " +
                "left join t_gw_system_main b on a.business_name = b.system_class_no " +
                "left join t_it_application_detail d on a.application_detail = d.mx_id " +
                "left join t_user e on a.user_id = e.userid where 1=1 ";
        return jdbcTemplate.query(sql, new VirtualRowMapper());
    }


    public List<VirtualManageExportFull> exportVirtualOutPutFull() {
        String sql = "select a.dev_id dev_id,b.op_name business_name, " +
                "(select dict_value from t_it_dict c where c.zd_id = a.network_segment) network_segment, " +
                "mx_name application_detail, " +
                "case when a.machine_area=0 then '生产网' when a.machine_area=1 then '办公网' " +
                "when a.machine_area=2 then '测试网' end machine_area, " +
                "virtual_name, " +
                "(select dict_value from t_it_dict f where f.zd_id = a.operation_sys) operation_sys, " +
                "(select dict_value from t_it_dict f where f.zd_id = a.machine_room) machine_room, " +
                "ip1,ip2,vcent_ip, " +
                "(select dict_value from t_it_dict g where g.zd_id = a.cpu) cpu, " +
                "(select dict_value from t_it_dict h where h.zd_id = a.memory) memory, " +
                "(select ip1 from t_it_server_device j where j.dev_id = a.virtual_ip) virtual_ip, " +
                "name ,bz,mac1,mac2,ip3,ip4,bf,department, " +
                "case when a.qj=1 then 'Nutanix_Cluster' when a.qj=2 then 'MainCluster' " +
                "when a.qj=3 then 'VMware_Cluster' when a.qj=4 then 'zbCluster' end qj, " +
                //				     "(select dict_value from t_dict i where i.zd_id = a.qj) qj, " +                  //20201207修复群集翻译问题
                "case when mark=1 then '正常' when mark=2 then '已删除' end mark " +
                "from t_it_virtual_device a " +
                "left join t_gw_system_main b on a.business_name = b.system_class_no " +
                "left join t_it_application_detail d on a.application_detail = d.mx_id " +
                "left join t_user e on a.user_id = e.userid where 1=1 ";
        return jdbcTemplate.query(sql, new VirtualRowMapperFull());
    }

    public List<ItVirtualDevice> searchVirtualDevice(String svd,boolean isLike) {
        if (isLike){
            return itVirtualDeviceRepo.searchVirtualDeviceSpecial(svd);
        } else {
            return itVirtualDeviceRepo.searchVirtualDeviceSpecialNotLike(svd);
        }

    }


//
//
//    //虚拟机数据导出
//    public List<VirtualDeviceExport> queryVirtualOutPut(String svd) {
//        String condition = "";
//        if (svd != null) {
//            condition += " and ip1 like '%" + svd + "%' or ip2 like '%" + svd + "%' or mac1 like '%" + svd + "%' or mac2 like '%" + svd + "%' ";
//        }
////		if(machine!=null) {
////			condition+=" and machine="+machine;
////		}
//        String sql = "select op_name business_name, " +
//                "(select dict_value from t_dict c where c.zd_id = a.network_segment) network_segment, " +
//                "mx_name application_detail, " +
//                "case when a.machine_area=0 then '生产网' when a.machine_area=1 then '办公网' " +
//                "when a.machine_area=2 then '测试网' end machine_area, " +
//                "virtual_name, " +
//                "(select dict_value from t_dict f where f.zd_id = a.operation_sys) operation_sys, " +
//                "ip1,ip2,vcent_ip, " +
//                "(select dict_value from t_dict g where g.zd_id = a.cpu) cpu, " +
//                "(select dict_value from t_dict h where h.zd_id = a.memory) memory, " +
//                "(select ip1 from t_service_device j where j.dev_id = a.virtual_ip) virtual_ip, " +
//                "user_name user_id,department, " +
//                "case when a.qj=1 then 'Nutanix_Cluster' when a.qj=2 then 'MainCluster' " +
//                "when a.qj=3 then 'VMware_Cluster' when a.qj=4 then 'zbCluster' end qj, " +
////				     "(select dict_value from t_dict i where i.zd_id = a.qj) qj, " +               //20201207修复群集翻译问题
//                "case when mark=1 then '正常' when mark=2 then '已删除' end mark " +
//                "from t_virtual_device a " +
//                "left join t_operation b on a.business_name = b.op_id " +
//                "left join t_yinyong_detail d on a.application_detail = d.mx_id " +
//                "left join t_admin_user e on a.user_id = e.user_id where 1=1 " + condition;
//        return jdbcTemplate.query(sql, new VirtualRowMapper());
//    }
//
//    //虚拟机数据全部导出
//    public List<VirtualDeviceExportFull> queryVirtualFullOutPut(String svd) {
//        String condition = "";
//        if (svd != null) {
//            condition += " and ip1 like '%" + svd + "%' or ip2 like '%" + svd + "%' or mac1 like '%" + svd + "%' or mac2 like '%" + svd + "%' ";
//        }
////		if(machine!=null) {
////			condition+=" and machine="+machine;
////		}
//        String sql = "select op_name business_name, " +
//                "(select dict_value from t_dict c where c.zd_id = a.network_segment) network_segment, " +
//                "mx_name application_detail, " +
//                "case when a.machine_area=0 then '生产网' when a.machine_area=1 then '办公网' " +
//                "when a.machine_area=2 then '测试网' end machine_area, " +
//                "virtual_name, " +
//                "(select dict_value from t_dict f where f.zd_id = a.operation_sys) operation_sys, " +
//                "ip1,ip2,vcent_ip, " +
//                "(select dict_value from t_dict g where g.zd_id = a.cpu) cpu, " +
//                "(select dict_value from t_dict h where h.zd_id = a.memory) memory, " +
//                "(select ip1 from t_service_device j where j.dev_id = a.virtual_ip) virtual_ip, " +
//                "user_name user_id,bz,mac1,mac2,ip3,ip4,bf,department, " +
//                "case when a.qj=1 then 'Nutanix_Cluster' when a.qj=2 then 'MainCluster' " +
//                "when a.qj=3 then 'VMware_Cluster' when a.qj=4 then 'zbCluster' end qj, " +
////				     "(select dict_value from t_dict i where i.zd_id = a.qj) qj, " +                  //20201207修复群集翻译问题
//                "case when mark=1 then '正常' when mark=2 then '已删除' end mark " +
//                "from t_virtual_device a " +
//                "left join t_operation b on a.business_name = b.op_id " +
//                "left join t_yinyong_detail d on a.application_detail = d.mx_id " +
//                "left join t_admin_user e on a.user_id = e.user_id where 1=1 " + condition;
//        return jdbcTemplate.query(sql, new VirtualRowMapperFull());
//    }
//
//    public Map<String, Object> getInfo(String devId) {
//        Map<String, Object> conditions = new HashMap<String, Object>();
//        conditions.put("dev_id", devId);
//        return BeanUtil.underline2Camel(generalDataManager.queryForMap("t_virtual_device", conditions));
//    }
//
//    ///////////////////////////////////////
//    //查询虚拟主机IP页面（无需入参的范例）
//    public List<Map<String, Object>> queryMainIpByDevId(String devId) {
//        String sql = "select dev_id,ip1 from t_service_device";
//        //List<Map<String, Object>> queryForList = jdbcTemplate.queryForList(sql, new Object[] {typeId});   测试看是否有数据
//        return BeanUtil.underline2Camel(jdbcTemplate.queryForList(sql, new Object[]{}));
//    }

}
